#######################################################################################################################
# File Name  : Makefile.RH850.GHS.GHS.LinkerScriptDefault                                                             #
# Description: Default Linker/Symbol Preprocessor command file generation                                             #
# Project    : Vector Basic Runtime System                                                                            #
# Module     : BrsHw for Platform Renesas RH850                                                                       #
#              and Compiler GreenHills                                                                                #
#                                                                                                                     #
#---------------------------------------------------------------------------------------------------------------------#
# COPYRIGHT                                                                                                           #
#---------------------------------------------------------------------------------------------------------------------#
# Copyright (c) 2018 by Vector Informatik GmbH.                                                  All rights reserved. #
#                                                                                                                     #
#---------------------------------------------------------------------------------------------------------------------#
# AUTHOR IDENTITY                                                                                                     #
#---------------------------------------------------------------------------------------------------------------------#
# Name                          Initials      Company                                                                 #
# ----------------------------  ------------  ------------------------------------------------------------------------#
# Steffen Frank                 visfsn        Vector Informatik GmbH                                                  #
# Benjamin Walter               visbwa        Vector Informatik GmbH                                                  #
# Jan Lutterbeck                visljn        Vector Informatik GmbH                                                  #
# David Feuerstein              visdfe        Vector Informatik GmbH                                                  #
# Sascha Mauser                 vismaa        Vector Informatik GmbH                                                  #
#---------------------------------------------------------------------------------------------------------------------#
# REVISION HISTORY                                                                                                    #
#---------------------------------------------------------------------------------------------------------------------#
# Version   Date        Author  Description                                                                           #
# --------  ----------  ------  --------------------------------------------------------------------------------------#
# 01.00.00  2014-06-10  visfsn  Initial version                                                                       #
# 01.01.00  2014-06-17  visfsn  Changed variable for memory mapping                                                   #
# 01.02.00  2014-07-30  visbwa  Adaptions for new BRS code structure                                                  #
# 01.02.01  2014-08-27  visljn  Linker labels for SDA optimization added                                              #
# 01.02.02  2014-09-02  visdfe  Added Data and Const Section for Mcal Fls Driver                                      #
# 01.03.00  2016-06-20  visbwa  adapted file header according to Brs_Template 2.00.01                                 #
# 01.04.00  2016-09-09  visbwa  Vectable separated, Makefile.RH850.GHS.GHS.LinkerScriptMultiCore introduced           #
# 01.04.01  2017-04-28  visbwa  Renamed LD_FILE_DEFAULT by LD_FILE directly                                           #
# 01.05.00  2018-01-18  visbwa  Removed outdated support for old OS (only OsGen7 supported within different file)     #
# 01.05.01  2018-01-30  vismaa  Added symbol _EXCEPTIONTABLE_START_ADDR and _VECTORTABLE_START_ADDR for usage in      #
#                               the startupcode                                                                       #
#######################################################################################################################

# Interrupt Vector Table base address for MasterCore
INTVECT_COREEXCEPTIONS_CORE0 = 0x00
INTVECT_EXTERNALINT_CORE0 =    0x200

#------------------------------------------------------------------------------
# rule to generate linker command file
#------------------------------------------------------------------------------

#############################################################################################################################################
# MAIN LINKER SCRIPT CODE
#############################################################################################################################################
define LD_FILE_DEFAULT
         $(ECHO) "MEMORY"                                                                                                  > $@; \
         $(ECHO) " {"                                                                                                     >> $@; \
         $(ECHO) "  iROM        : ORIGIN = 0x00000000, LENGTH = 3072k"                                                    >> $@; \
         $(ECHO) "  iRAM        : ORIGIN = 0xFEDE0000, LENGTH = 64k"                                                      >> $@; \
         $(ECHO) " }"                                                                                                     >> $@; \
         $(ECHO) ""                                                                                                       >> $@; \
         $(ECHO) "SECTIONS"                                                                                               >> $@; \
         $(ECHO) " {"                                                                                                     >> $@; \
         $(ECHO) "/* Start of internal RAM area (iRAM) */"                                                                >> $@; \
         $(ECHO) "  .sdabase  align(4)               :>iRAM   /* initialize globalpointer GP for SDA addressing */"       >> $@; \
         $(ECHO) "  .signature               align(4):>."                                                                 >> $@; \
         $(ECHO) "  .R_FCL_CODE_RAM          align(4):>."                                                                 >> $@; \
         $(ECHO) "  .text     align(16)              :>.      /* program code area */"                                    >> $@; \
         $(ECHO) "  .rozdata                         :>.      /* constant datas in ZDA area */"                           >> $@; \
         $(ECHO) "  .robase   align(4)               :>.      /* initialize textpointer TP for SDA addressing */"         >> $@; \
         $(ECHO) "  .rosdata  align(4)               :>.      /* constant datas in SDA area */"                           >> $@; \
         $(ECHO) "  .rodata   align(4)               :>.      /* constant datas in normal area */"                        >> $@; \
         $(ECHO) "  .data                            :>.      /* initialized data */"                                     >> $@; \
         $(ECHO) "  .bss      align(4)               :>.      /* zero initialized data*/"                                 >> $@; \
         $(ECHO) "  .sdata    align(4)               :>.      /* initialized data in SDA area */"                         >> $@; \
         $(ECHO) "  .sbss            align(4)              :>.      /* zero initialized data in SDA area*/"               >> $@; \
         $(ECHO) "  .tdata    align(4) MAX_SIZE(256) :>.      /* initialized and zero-initialized data in TDA area */"    >> $@; \
         $(ECHO) "  .zdabase                         :>."                                                                 >> $@; \
         $(ECHO) "  .zdata                           :>.      /* initialized data in ZDA area*/"                          >> $@; \
         $(ECHO) "  .zbss     align(4)               :>.      /* zero initialized data in ZDA area*/"                     >> $@; \
         $(ECHO) "  .romdata  ROM(.data)             :>.      /* constant data to initialize variables */"                >> $@; \
         $(ECHO) "  .romzdata ROM(.zdata)            :>.      /* constant data to initialize variables in ZDA area */"    >> $@; \
         $(ECHO) "  .romsdata ROM(.sdata)            :>.      /* constant data to initialize variables in SDA area */"    >> $@; \
         $(ECHO) "  .romtdata ROM(.tdata)            :>.      /* constant data to initialize variables in TDA area */"    >> $@; \
         $(ECHO) "  .secinfo                         :>.      /* constant data to initialize variables in TDA area */"    >> $@; \
         $(ECHO) "  .R_FCL_CODE_ROMRAM       align(4):>."                                                                 >> $@; \
         $(ECHO) "  .R_FCL_DATA              align(4):>."                                                                 >> $@; \
         $(ECHO) "  .R_FCL_CODE_USRINT       align(4):>.      /* Interrupt code located in RAM */"                        >> $@; \
         $(ECHO) "  .R_FCL_CODE_USR          align(4):>.      /* User code located in RAM */"                             >> $@; \
         $(ECHO) "  .R_FCL_CODE_ROM          align(4):>.      /* FCL code in ROM */"                                      >> $@; \
         $(ECHO) "  .R_FCL_CONST             align(4):>.      /* FCL constants in ROM */"                                 >> $@; \
         $(ECHO) "  .R_FCL_CODE_RAM_EX_PROT  pad(0x20) align(4):>. /* ECC Exception protection */"                        >> $@; \
         $(ECHO) "  .stack    align(4) pad(0x300)    :>.      /* definition of stack size */"                             >> $@; \
         $(ECHO) " }"                                                                                                     >> $@; \
         $(ECHO) "-map"                                                                                                   >> $@; \
         $(ECHO) "-sda"                                                                                                   >> $@;
endef

LD_FILE = $(LD_FILE_DEFAULT)